<?php
/**
 * @file 3gplex/includes/pathauto.inc
 * 
 * Pathauto contrib module configuration API.
 * 
 */

require_once('./'. drupal_get_path('module', 'drupalplex') .'/includes/module.inc');

/**
 * Pathauto contrib module wrapper.
 * 
 * This module permits to set rules to automatically alias content on creation or update.
 * E.G. "node/943" can be aliased as "catalog/cd/the-best-of-james-cotton" using pattern
 * "catalog/[node-type]/[node-title-raw]".
 * 
 * The wildwords in pattern are provided by the "token" module.
 */
class plex_pathauto extends plex_module
{
	function get_description()
	{
		return "Configures and loads API for Drupal contrib pathauto module:
		Automatic URL aliases following patterns";
	}
	protected $requires = array( 'path', 'token' );
	/**
	 * Sets pattern pathauto will use to automatically alias term pages.
	 */
	function set_taxonomy_pattern($vid, $pattern)
	{
		/// @todo verify if this is a numeric value or not
		variable_set('pathauto_taxonomy_'.(int)$vid.'_pattern', (string)$pattern);
		return true;
	}

	/**
	 * Sets pattern pathauto will use to automatically alias nodes.
	 */
	function set_node_type_pattern($node_type, $pattern)
	{
		variable_set('pathauto_node_'.(string)$node_type.'_pattern', (string)$pattern);
		return true;
	}
}

